package com.code.design.model.demo.decorator.concretedecorator;

import com.code.design.model.demo.decorator.component.Car;
import com.code.design.model.demo.decorator.decorator.CarDecorator;

/**
 * 具体的装饰器实现类，也就是ConcreteDecorator角色。这些装饰器同样实现了run的行为，一方面会调用被包装对象的run方法，一方面会进行某些扩展操作（比如自动驾驶、飞行）
 *
 * @author tangyifei
 */
public class AutoCarDecorator extends CarDecorator {

    public AutoCarDecorator(Car decoratedCar) {
        super(decoratedCar);
    }

    @Override
    public void run() {
        decoratedCar.run();
        autoRun();
    }

    private void autoRun() {
        System.out.println("开启自动驾驶");
    }
}
